package com.signavio.analytics.handler;

import javax.servlet.ServletContext;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.signavio.analytics.business.ExampleAccessHelper;
import com.signavio.analytics.filter.CachedFilterResult;
import com.signavio.platform.annotations.HandlerConfiguration;

@HandlerConfiguration(uri="/analyticsnrinstances", rel="analyticsnrinstances", isSBOHandler=false)
public class ExampleHandler extends
		AbstractAnalyticsHandlerUsingFilter {

	private final ExampleAccessHelper helper;
	
	public ExampleHandler(ServletContext servletContext) {
		super(servletContext);
		helper = new ExampleAccessHelper();
	}

	@Override
	protected JSONArray getAnalysisResult(CachedFilterResult filterResult,
			JSONObject specificParams) throws JSONException {
		JSONArray result = new JSONArray();
		
		result.put(helper.getNrOfInstances(filterResult.getSelectedModelInstanceIds()));
		
		return result;
	}
	


}
